<template>
  <div class="wode">
    <div class="mine"
         @click="mineAction">
      <span class="iconfont icon-touxiang"></span>
      <div class="lr">
        <span v-if="!lshow">登录/注册</span>
        <span v-if="lshow">{{username}}</span>
        <p>
          <i class="iconfont icon-shouji"></i>
          <span>暂无绑定手机号</span>
        </p>
      </div>
      <div class="right">
        <i class="iconfont icon-fanhui1"></i>
      </div>
    </div>

    <div class="infor">
      <ul class="infor_con">
        <li class="ye"
            @click="balanceAction">
          <p v-if="!pshow">0.00</p>
          <p v-if="pshow">{{points.balance}}</p>
          <span>我的余额</span>
        </li>
        <li class="yh"
            @click="disAction">
          <p v-if="!pshow">0</p>
          <p v-if="pshow">{{points.gift_amount}}</p>
          <span>我的优惠</span>
        </li>
        <li class="jf"
            @click="creditAction">
          <p v-if="!pshow">0</p>
          <p v-if="pshow">{{points.brand_member_new}}</p>
          <span>我的积分</span>
        </li>
      </ul>
    </div>

    <div class="profile profile1">
      <div class="line1"
           @click="orderAction">
        <span>
          <i class="iconfont icon-dingdan"></i>
          <span>我的订单</span>
        </span>
        <i class="iconfont icon-fanhui1"></i>
      </div>
      <div class="line1"
           @click="pointsAction">
        <span>
          <i class="iconfont icon-shangcheng"></i>
          <span>积分商城</span></span>
        <i class="iconfont icon-fanhui1"></i>
      </div>
      <div class="line1 line2"
           @click="vipAction">
        <span>
          <i class="iconfont icon-huiyuanhuangguanguanjun-xianxing"></i>
          <span>饿了么会员卡</span>
        </span>
        <i class="iconfont icon-fanhui1"></i>
      </div>
    </div>
    <div class="profile">
      <div class="line1"
           @click="serviceAction">
        <span>
          <i class="iconfont icon-changyonglogo40"></i>
          <span>服务中心</span>
        </span>
        <i class="iconfont icon-fanhui1"></i>
      </div>
      <div class="line1"
           @click="loadAction">
        <span>
          <i class="iconfont icon-changyonglogo40"></i>
          <span>下载饿了么APP</span>
        </span>
        <i class="iconfont icon-fanhui1"></i>
      </div>
    </div>

  </div>

</template>

<script>
export default {
  name: 'Mine',
  data: function () {
    return {
      username: localStorage.getItem('username'),
      lshow: false,
      points: [],
      pshow: false,
    }
  },
  created () {
    if (localStorage.getItem('code') == 200) {
      this.lshow = true;
      this.$axios.get('https://elm.cangdu.org/v1/user?', {
        params: {
          user_id: localStorage.getItem('uid')
        }
      }).then(res => {
        // console.log(res);
        this.pshow = true;
        this.points = res.data;
      }).catch(err => console.log(err));
    }
  },
  methods: {
    //登录注册
    mineAction () {
      if (localStorage.getItem('username') == null) {
        this.$router.push({ name: 'Login' });

      } else if (localStorage.getItem('code') == 200) {
        this.$router.push({ name: 'UserInfor' })
      }
    },
    //我的订单
    orderAction () {
      this.$router.push({ name: "Order" });
    },
    //服务中心
    serviceAction () {
      this.$router.push({ name: 'ServiceCenter' })
    },
    //我的余额
    balanceAction () {
      this.$router.push({ name: 'AccountBalance' })
    },
    //我的积分
    creditAction () {
      this.$router.push({ name: 'Credit' })
    },
    //会员中心
    vipAction () {
      this.$router.push({ name: 'Vip' })
    },
    //我的优惠
    disAction () {
      this.$router.push({ name: 'Discount' })
    },
    //积分商城
    pointsAction () {
      this.$router.push({ name: 'PointsMall' })
    },
    //下载饿了么APP
    loadAction () {
      this.$router.push({ name: 'Dowload' })
    }
  },
}
</script>

<style lang="less">
.wode {
  height: 667px;
  background-color: #f5f5f5;
}
.mine {
  background-color: #3190e8;
  color: white;
  display: flex;
  align-items: center;
  padding: 15px;
  box-sizing: border-box;
  border-top: 0.1px solid #ccc;

  .icon-touxiang {
    font-size: 60px;
    background-color: white;
    color: #ccc;
    border-radius: 50%;
    margin-right: 15px;
  }

  .lr {
    margin-right: 140px;

    span {
      font-size: 18px;
      font-weight: 600;
    }
    p {
      span {
        font-size: 14px;
      }
    }
  }
}

.infor {
  font-size: 0;
  margin-bottom: 10px;
  background-color: white;

  .infor_con {
    display: flex;
    justify-content: space-around;

    li {
      padding: 20px 30px 10px;
    }
    p {
      text-align: center;
    }

    .ye {
      p {
        font-size: 28px;
        color: #f90;
        font-weight: 600;
      }
    }
    .yh {
      border-left: 0.1px solid #ccc;
      border-right: 0.1px solid #ccc;

      p {
        font-size: 28px;
        color: #ff5f3e;
        font-weight: 600;
      }
    }
    .jf {
      p {
        font-size: 28px;
        color: #6ac206;
        font-weight: 600;
      }
    }

    span {
      font-size: 13px;
    }
  }
}

.profile {
  background-color: white;

  .line1 {
    padding: 15px;
    border-bottom: 0.1px solid #ccc;
    display: flex;
    justify-content: space-between;
  }
  .iconfont {
    margin-right: 10px;
  }
  span {
    font-size: 16px;
    color: #333;
  }
  .icon-shangcheng {
    color: orangered;
  }
  .icon-huiyuanhuangguanguanjun-xianxing {
    color: gold;
  }
  .icon-changyonglogo40 {
    background-color: #3190e8;
    color: white;
  }
}

.profile1 {
  margin-bottom: 10px;
}
</style>